/****** 
Commerce for Umbraco SQL Updates
- Motus Connect - http://www.motusconnect.com/

******/

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

/****** Object:  StoredProcedure [dbo].[CSK_Store_Product_GetByManufacturerID] ******/
	ALTER PROCEDURE [dbo].[CSK_Store_Product_GetByManufacturerID]
	(
		@manufacturerID int,
		@categoryID int
	)
	AS
	SELECT     productID, sku, productGUID, productName, shortDescription, manufacturerID, statusID, productTypeID, shippingTypeID, shipEstimateID, taxTypeID, stockLocation, 
	                      ourPrice, retailPrice, weight, currencyCode, unitOfMeasure, adminComments, length, height, width, dimensionUnit, isDeleted, listOrder, RatingSum, 
	                      totalRatingVotes, createdOn, createdBy, modifiedOn, modifiedBy, shippingEstimate, leadTimeDays, imageFile, categoryID, rating, manufacturer, status,
	                       taxType, taxCode, shippingType, shippingCode
	FROM         vwProduct
	WHERE     (manufacturerID = @manufacturerID) AND (productID IN
	                          (SELECT     productID
	                            FROM          CSK_Store_Product_Category_Map
	                            WHERE      (categoryID IN
	                                                       (SELECT     Id
	                                                         FROM          dbo.GetChildren(@categoryID) AS GetChildren_1)))) AND (statusID <> 99)
	ORDER BY listOrder
	RETURN 
GO

/****** Object:  StoredProcedure [dbo].[CSK_Store_Product_GetByCategoryID] ******/
	ALTER PROCEDURE [dbo].[CSK_Store_Product_GetByCategoryID]
	(
		@categoryID int
	)
	AS
	SELECT     productID, sku, productGUID, productName, shortDescription, manufacturerID, statusID, productTypeID, shippingTypeID, shipEstimateID, taxTypeID, stockLocation, 
	                      ourPrice, retailPrice, weight, currencyCode, unitOfMeasure, adminComments, length, height, width, dimensionUnit, isDeleted, listOrder, RatingSum, 
	                      totalRatingVotes, createdOn, createdBy, modifiedOn, modifiedBy, shippingEstimate, leadTimeDays, imageFile, categoryID, rating, manufacturer, status,
	                       taxType, taxCode, shippingType, shippingCode
	FROM         vwProduct
	WHERE     (productID IN
	                          (SELECT     productID
	                            FROM          CSK_Store_Product_Category_Map
	                            WHERE      (categoryID IN
	                                                      
	                                                       (SELECT     Id
	                                                         FROM          dbo.GetChildren(@categoryID) AS GetChildren_1)))) AND (statusID <> 99)
	ORDER BY listorder
	RETURN 
GO
